package com.knowledge.knowledge_notes.common;

import lombok.Getter;

@Getter
public class ResultVo {
    private int code;
    private String msg;
    private Object data;

    public ResultVo(ResultCode resultCode) {
        this.code = resultCode.getCode();
        this.msg = resultCode.getMsg();
    }

    public ResultVo(ResultCode resultCode,Object data){
        this(resultCode);
        this.data = data;
    }

    public ResultVo(ResultCode resultCode,String msg){
        this(resultCode);
        this.msg = msg;
    }

    public static ResultVo OK(){
        return new ResultVo(ResultCode.SUCCESS);
    }

    public static ResultVo OK(Object data){
        return new ResultVo(ResultCode.SUCCESS, data);
    }

    public static ResultVo FAIL(){
        return new ResultVo(ResultCode.FAILED);
    }
    public static ResultVo FAIL(String msg){
        return new ResultVo(ResultCode.FAILED,msg);
    }

    public static ResultVo FAIL(Object data){
        return new ResultVo(ResultCode.FAILED,data);
    }
}
